package cn.supermaster.management.web.rest.system;

import cn.supermaster.management.common.annotation.Log;
import cn.supermaster.management.common.enums.BusinessType;
import cn.supermaster.management.common.page.TableDataInfo;
import cn.supermaster.management.common.response.WebResponse;
import cn.supermaster.management.system.domain.SystemPost;
import cn.supermaster.management.web.service.system.ISPostService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * All rights Reserved, Designed By www.super-bytecode.com
 *
 * @ProjectName: supermaster-management
 * @Package: cn.supermaster.management.web.rest.system
 * @ClassName: SystemPostRestController
 * @Description: [岗位信息操作处理]
 * <p> </p>
 * @Author: [Lance Ting]
 * @Date: 2021/1/12 0:04
 * @Version: V1.0
 * @Copyright: 2021 www.super-bytecode.comn Inc. All rights reserved.
 * TODO: 注意,本文件Lance Ting所作,如果转载或使用请标明具体出处!
 **/
@RestController
@RequestMapping("/system/post")
public class SystemPostRestController {

    @Autowired
    private ISPostService postService;

    @RequiresPermissions("system:post:list")
    @PostMapping("/list")
    public TableDataInfo queryPostListByCondition(SystemPost post) {
        return postService.queryPostListByCondition(post);
    }

    @Log(title = "岗位管理", businessType = BusinessType.EXPORT)
    @RequiresPermissions("system:post:export")
    @PostMapping("/export")
    public WebResponse doExportPostList(SystemPost post) {
        return postService.doExportPostList(post);
    }

    @RequiresPermissions("system:post:remove")
    @Log(title = "岗位管理", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    public WebResponse doRemovePostInformation(String ids) {
        return postService.doRemovePostInformation(ids);
    }

    /**
     * 新增保存岗位
     */
    @RequiresPermissions("system:post:add")
    @Log(title = "岗位管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public WebResponse doAddPostInformation(@Validated SystemPost post) {
        return postService.doAddPostInformation(post);
    }

    /**
     * 修改保存岗位
     */
    @RequiresPermissions("system:post:edit")
    @Log(title = "岗位管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public WebResponse doModifyPostInformation(@Validated SystemPost post) {
        return postService.doModifyPostInformation(post);
    }

    /**
     * 校验岗位名称
     */
    @PostMapping("/checkPostNameUnique")
    public String checkPostNameUnique(SystemPost post) {
        return postService.checkPostNameUnique(post);
    }

    /**
     * 校验岗位编码
     */
    @PostMapping("/checkPostCodeUnique")
    public String checkPostCodeUnique(SystemPost post) {
        return postService.checkPostCodeUnique(post);
    }
}